#include <algorithm>
#include <ctype.h>
#include<iostream>
#include<vector>
using namespace std;
class Solution {
public:
    bool isPalindrome(string s) {
        string s1;
        string s2;
        int left=0,right=s.size()-1;
        for(;left<right;left++,right--)
        {
            
            while(left<s.size()&&(!isalpha(s[left])&&!isdigit(s[left])))left++;
            while(right<s.size()&&(!isalpha(s[right])&&!isdigit(s[right])))right--;
            if(left<right)
            {
                s[left]=tolower(s[left]);
                s1.push_back(s[left]);
                }
            if(left<right){
                s[right]=tolower(s[right]);
                s2.push_back(s[right]);
                 
                }
        }
        return s1==s2;
    }
};
class Solution1 {
public:
    bool isPalindrome(string s) {
        string ans;
        for(int i=0;i<s.size();i++)
        {
            if(isupper(s[i]))ans+=tolower(s[i]);
            else if(islower(s[i])||isdigit(s[i]))ans+=s[i];
        }
        string re=ans;
       reverse(ans.begin(),ans.end());
       return ans==re;
    }
};
int main()
{
    Solution s1;
    s1.isPalindrome("Marge, let's \"[went].\" I await {news} telegram.");
}